import socket
import sys
import time


HOST = '127.0.0.1'
PORT = 32227

s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
print ('socket created')

try:
	s.bind((HOST,PORT))
except socket.error as msg:
	print ('Bind failed. Error Code:'+str(msg[0])+'Message'+msg[1])
	sys.exit()

print ('Socket bind complete')

s.listen(10)
print ('Socket now listening')

while 1:
	conn , addr = s.accept()
	print('Connection Success')
	print ('Connected with'+addr[0]+':'+str(addr[1]))
	data = conn.recv(1024,0)
	print(type(data))
	print(data)
	ff = data.decode()
	print(type(ff))

	print(ff)
	# ff = data.decode("utf-8")
	# print (data)

	temp=str(data)
	print ("1111"+temp)
	if temp == "1":

		print ("好的"+'1')
		break
	if temp == "1":
		print ('2')
		break


conn.close()
s.close()